package com.snail.controller;

import co.elastic.clients.elasticsearch.core.SearchResponse;
import com.snail.model.entity.Product;
import com.snail.model.pojo.SearchHitResult;
import com.snail.service.BizProductService;
import com.snail.service.BizSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Objects;

/**
 * @author cici
 * @description product
 * @date 2025/8/19 14:00
 */
@RequestMapping("/searchProduct")
@RestController
public class BizProductController {
    @Autowired
    BizProductService bizProductService;

    @GetMapping("/product")
    public ResponseEntity<?> searchProductByES(@RequestParam String keyword,@RequestParam int page,@RequestParam int size) {
        SearchHitResult<Product> response = bizProductService.SearchAsHot(keyword,page,size);
        SearchHitResult<Product> resp = bizProductService.searchAndSerialize(keyword,page,size);
        System.out.println(resp);
        return ResponseEntity.ok(resp);
    }
}
